import * as actionType from '../constants/store.js'

const initialStore = []

export default function store(state = initialStore, action) {
    switch (action.type) {
      case actionType.STORE_UPDATE:
          return action.data
      case actionType.STORE_ADD:
          state.unshift(action.data)
          return state
      case actionType.STORE_REMOVE:
          return state.filter(item => {
            if(item.id != action.data.id) {
              return item
            }
          })
      default :
          return state
    }
}